import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();

        int[] sum = new int[2]; // 统计字符串中所有0和1的个数
        for (char ch : s.toCharArray()) {
            sum[ch - '0']++;
        }

        int left = 0, right = 0, ret = 0, half = n / 2;
        int[] count = new int[2]; // 统计窗口内0和1的个数
        while (right < n - 1) { // 细节问题
            count[s.charAt(right) - '0']++;
            while (right - left + 1 > half) {
                count[s.charAt(left++) - '0']--;
            }
            if (right - left + 1 == half) {
                if (count[0] * 2 == sum[0] && count[1] * 2 == sum[1]) {
                    ret += 2;
                }
            }
            right++;
        }

        System.out.println(ret);
    }
}
